package com.practice;

public class demo17 {
    public static void main(String[] args) {
        //计数器数字个数
        int count = 0;
        //计数器打印个数
        int count1 = 0;
        for (int i = 1000; i < 10000; i++) {
            int g = i % 10;
            int s = i / 10 % 10;
            int b = i / 100 % 10;
            int q = i / 1000 % 10;
            if (g + b == s + q) {
                count++;
                count1++;
                System.out.print(i + " ");
                if (count1 % 5 == 0) {
                    System.out.println();
                }
            }
        }
        System.out.println(count);
    }
}
